import request from '@/utils/request'
import qs from 'qs'

// 获取餐桌全部位置selectItem
export function deskRoomSelectItem() {
  return request({
    url: '/merchant/desk_room/select_item',
    method: 'get'
  })
}

// 获取位置列表
export function deskRoomList() {
  return request({
    url: '/merchant/desk_room/list',
    method: 'get',
  })
}


// 获取桌形列表
export function deskTypeList() {
  return request({
    url: '/merchant/desk_type/list',
    method: 'get',
  })
}


// 获取餐桌全部桌形selectItem
export function deskTypeSelectItem() {
  return request({
    url: '/merchant/desk_type/select_item',
    method: 'get'
  })
}

//获取所有餐桌列表数据
export function showDeskInfo() {
  return request({
    url: '/merchant/desk/show_desk_info',
    method: 'get',
    params: {
      storeId: sessionStorage.getItem('storeId')
    }
  })
}


// 获取餐桌列表
export function deskList(pageNumber, pageSize, data) {
  return request({
    url: '/merchant/desk/list_rewrite',
    method: 'get',
    params: {
      pageNumber,
      pageSize,
      deskRoomId: data.deskRoomId,
      deskTypeId: data.deskTypeId,
      status: data.status, //餐桌状态
      storeId: sessionStorage.getItem('storeId')
    }
  })
}


// 修改餐桌
export function deskUpdate(desk) {
  console.log(desk);
  return request({
    url: '/merchant/desk/update',
    method: 'post',
    data: qs.stringify(
      desk
    )
  })
}



// 获取餐桌茶位费
export function deskTeaChargeQuery() {
  return request({
    url: '/merchant/tea_charge/find_one',
    method: 'get'
  })
}

// 修改餐桌茶位费
export function deskTeaChargeUpdate(id, money) {
  return request({
    url: '/merchant/tea_charge/update',
    method: 'post',
    data: qs.stringify({
      id: id,
      money: money
    }, {indices: false})
  })
}

//空闲可调换的餐桌
export function freeDesks(rid, tid) {
  return request({
    url: '/merchant/desk/show_free_desks',
    method: 'get',
    params: {
      deskRoomId: rid,
      deskTypeId: tid,
      storeId: sessionStorage.getItem('storeId')
    }
  })
}

//锁定餐桌换桌
export function changeLockDesk(oid, nid) {
  return request({
    url: '/merchant/desk/lock_desk_change',
    method: 'post',
    data: qs.stringify({
      sourceDeskId: oid,
      targetDeskId: nid
    })
  })
}
//就餐餐桌换桌
export function repastDeskChange(oid, nid) {
  return request({
    url: '/merchant/desk/repast_desk_change',
    method: 'post',
    data: qs.stringify({
      sourceDeskId: oid,
      targetDeskId: nid
    })
  })
}


